package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {


    /*
    * 查询购物表中是否有数据
    * */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /*
    * 根据ID修改数量
    * */
    @Update("update shopping_cart set number = #{number} where id =#{id}")
    void updateNumberById(ShoppingCart shoppingCart);

    /*
    * 向购物表中添加菜品信息或者套餐信息
    * */
    void insert(ShoppingCart shoppingCart);

    /*
    * 清空购物车
    * */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long userId);

    /*
    * 把购物车的信息添加到数据库中
    * */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
